<template>
  <div class="pages">
    <div class="hearder-top">
      <span class="fa fa-chevron-left" @click="back"></span>
      <span>商品详情</span>
      <span></span>
    </div>
    <div class="page">
      <Swiper 
      :list='skindItem.pics' 
      auto 
      loop 
      dots-position="center" 
      height="250px"
      ></Swiper>
      <div id="goodlist">
        <div id="goodlist1">
          <p><span style="font-weight:bold">{{skindItem.goodsname}}</span></p>
          <p style="color:red">
            <span class="fa fa-share-alt" style="margin-left:20px"></span>
            <br>
            <span style="font-size:12px">分享有赏</span>
          </p>
        </div>
        <p>
          <span style="color:red;font-size:18px;font-weight:bold;">￥{{skindItem.price}}</span>
          <span style="text-decoration:line-through;margin-left:30px">￥{{skindItem.old}}</span>
        </p>
        <p id="kucun">
          <span>库存:{{skindItem.stock}}</span>
          <span>已销售:{{skindItem.sales}}件</span>
          <span>{{skindItem.site}}</span>
        </p>
        <div class="shop">
          <p class="hanliang" @click="showCarClick">
            <span>请选择 颜色 尺码</span>
            <span class="fa fa-chevron-right"></span>
          </p>
        </div>
        <div class="shop">
          <p class="hanliang">
            <span>宝贝评价（{{skindItem.score}}）</span>
            <span class="fa fa-chevron-right" @click="back"></span>
          </p>
        </div>
      </div>
      <div class="goods-tabbar">
        <div>
          <div class="clumn">
            <span class="fa fa-shopping-basket" style="font-size:16px"></span>
            <p>店铺</p>
          </div>
          <div class="clumn">
            <span class="fa fa-commenting-o" style="font-size:16px"></span>
            <p>客服</p>
          </div>
          <div class="clumn">
            <span class="fa fa-star-o" style="font-size:16px"></span>
            <p>收藏</p>
          </div>
        </div>
        <div @click="showCarClick">加入购物车</div>
        <div>立即购买</div>
      </div>
    </div>
    <transition name="aniMask">
            <div 
                v-show="showCar" 
                class="car-mask" 
                @click="hideShowCar"
            >
            </div>
        </transition>
        <transition name="aniEdit">
          <Addgood v-if="showCar"></Addgood>
        </transition>
  </div>
</template>

<script>

  import { mapState } from 'vuex';
  import { Swiper } from 'vux'
  import Addgood from '@/components/Addgood'
  export default {
    mounted: function () {
      var params = {
        _id: this.$route.query._id
      }
      this.$store.dispatch("requestSkindItem", params)
        .then(res => {
          this.$store.commit("setSkindItem", res.data.data);
        });
    },
    methods:{
        back:function(){
            history.back();
        },
        showCarClick:function(){
          console.log(123)
          this.$store.commit("setShowCar",true)
        },
        hideShowCar:function(){
          this.$store.commit("setShowCar",false)
        }
    },
    computed: {
      ...mapState([
        "skindItem",
        "showCar"
      ])
    },
    components: {
      Swiper,
      Addgood
    }
  }

</script>

<style scoped>
.pages{
  background-color:white;
}
  .page {
    height: calc(100vh - 80px);
    margin-top: 42px;
  }

  .hearder-top {
    background-color: red;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 40px;
    z-index: 1;
    display: flex;
    justify-content: space-around;
  }

  .hearder-top span {
    color: white;
    line-height: 40px;
  }

  #goodlist {
    font-size: 14px;
  }

  #goodlist1 {
    display: flex;
    width: 100%;
  }

  #goodlist1 p:nth-of-type(1) {
    width: 80%;
  }

  #goodlist1 p:nth-of-type(2) {
    width: 20%;
  }

  #goodlist p {
    text-align: left;
    margin-left: 5px;
    margin: 8px 5px;
  }

  #kucun {
    display: flex;
    justify-content: space-around;
    font-size: 12.2px;
    text-align: left;
  }

  .shop {
    width: 100%;
    background-color: #f5f5f5;
    height: 35px;
    line-height: 35px;
    border-bottom: solid 1px #e5e5e5;
  }

  .hanliang {
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    margin: 0 8px;
  }

  .hanliang span {
    line-height: 35px;
    color: #666666;
  }

  #car {
    width: 100%;
    height: 45px;
    line-height: 45px;
    display: flex;
    justify-content: space-between;
    background-color: #eeeeee;
    position: absolute;
    bottom: 0;
    left: 0;
  }

  .goods-tabbar {
    border-top: 1px solid #ddd;
    position: fixed;
    background-color: white;
    width: 100vw;
    height: 45px;
    bottom: 0;
    left: 0;
    display: flex;
  }

  .goods-tabbar>div {
    width: 30%;
    color: white;
  }

  .goods-tabbar>div:nth-of-type(1) {
    width: 40%;
    display: flex;
    color: #333;
    font-size: 12px;
  }

  .goods-tabbar>div:nth-of-type(2) {
    text-align: center;
    background-color: orange;
    line-height: 45px;
  }

  .goods-tabbar>div:nth-of-type(3) {
    text-align: center;
    background-color: orangered;
    line-height: 45px;
  }
  .clumn {
    text-align: center;
    width: 33.33%;
    padding-top: 6px;
  }
  .clumn p {
    margin: 0;
  }


.car-mask{
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }
    /*蒙灰层动画*/
    .aniMask-enter,.aniMask-leave-to{
        opacity: 0;
    }
    .aniMask-enter-active,.aniMask-leave-active{
        transition: all 0.7s;
    }
    .aniMask-enter-to,aniMask-leave{
        opacity: 1;
    }
    /*编辑层动画*/
    .aniEdit-enter,.aniEdit-leave-to{
        opacity: 0 ;
        height: 0 !important;
    }
    .aniEdit-enter-active,.aniEdit-leave-active{
        transition: all 0.7s;
    }
    .aniEdit-enter-to{
        opacity: 1;
        height: 65vh !important;
    }
  
</style>